# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=slidge-matridge
pkgver=0_git20240208
_gitrev=c1f6bbf94971f4b6e378e7959c717da7cf41d842
pkgrel=1
pkgdesc="Feature-rich Matrix to XMPP puppeteering gateway"
url="https://slidge.im/matridge/"
arch="noarch"
license="AGPL-3.0-or-later"
depends="
	py3-async-lru
	py3-atomicwrites
	py3-beautifulsoup4
	py3-cachetools
	py3-matrix-nio
	py3-olm
	py3-peewee
	py3-slidge-style-parser
	slidge
	"
makedepends="
	py3-gpep517
	py3-poetry-core
	"
checkdepends="
	py3-pytest
	py3-pytest-asyncio
	py3-xmldiff
	"
pkgusers="slidge"
pkggroups="slidge"
subpackages="$pkgname-openrc $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~nicoco/matridge/archive/$_gitrev.tar.gz
	matridge.conf
	"
builddir="$srcdir/matridge-$_gitrev"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -dm750 -o slidge -g slidge \
		"$pkgdir"/etc/slidge
	install -Dm640 -o slidge -g slidge \
		"$srcdir"/matridge.conf \
		-t "$pkgdir"/etc/slidge/

	install -dm755 "$pkgdir"/etc/init.d
	ln -s slidge "$pkgdir"/etc/init.d/slidge.matridge
}

sha512sums="
23d0ca3574812c62ffcbee111499eb04ac0d54115ee619c121e48251780c1b4f6d9bdc668f2e00af5d1fc4fe85cdd35bc5c7a08a4c6e134298cf018e59fe1fc6  slidge-matridge-0_git20240208.tar.gz
e5f5c7f1f0ad2c96d04f0f2eb8eaea856db99f0cab92a05b080bce83a2fea4848a0573ff5e0490dee92c5d6d66dd1201f8ff2ab5c5717ae11f2ff7a193ac8a2d  matridge.conf
"
